<template>
	<view class="nav">
		<view class="content">
			<!-- 家长 -->
			<view class="list" v-for="(item,index)  in student" :key="index" @tap="toindex(item,0)"
				v-if="student.length>0">
				<view class="usershenfen">
					<text>{{item.student_name}}</text>
					<text>的</text>
					<text>{{item.content}}</text>

				</view>
				<view class="textboxone">
					<text class="textbox">{{item.school_name}}</text>
					<text>{{item.class_name}}</text>
				</view>
				<view class="shenfen">
					<text>选择身份</text>
				</view>
			</view>
			<!-- 老师 -->
			<view class="list" v-for="(item,index)  in teacher" :key="index" @tap="toindex(item,1)"
				v-if="teacher.length>0">
				<view class="usershenfen">
					<text>{{item.name}}</text>
					<text>的</text>
					<text>{{item.zhiwei}}</text>
					<text v-if="item.bzr==1" class="bzr">班主任</text>
				</view>
				<view class="textboxone">
					<text class="textbox">{{item.school}}</text>
					<text>{{item.name}}</text>
				</view>
				<view class="shenfen">
					<text>选择身份</text>
				</view>
			</view>
			<!-- 教育局 -->
			<view class="list" v-for="(item,index)  in eduadmin" :key="index" @tap="toindex(item,2)"
				v-if="eduadmin.length>0">
				<view class="usershenfen">
					<text>{{item.name}}</text>
					<!-- <text>的</text>
					<text>{{item.zhiwei}}</text>
					<text v-if="item.bzr==1" class="bzr">班主任</text> -->
				</view>
				<view class="textboxone">
					<text>{{item.company_name}}</text>
				</view>
				<view class="shenfen">
					<text>选择身份</text>
				</view>
			</view>
			<kongyemian v-if="student.length<1 && teacher.length<1 && eduadmin.length<1" :isLoding="loding"></kongyemian>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapGetters,
		mapMutation,
		mapActions
	} from 'vuex';
	export default {
		computed: {
			...mapState({
				userInfo: state => state.user.userInfo,
				isLogin: state => state.user.isLogin,
				imlogin: state => state.timStore.imlogin
			})
		},
		data() {
			return {
				student: [],
				teacher: [],
				eduadmin: [],
				loding: true
			}
		},
		methods: {

			getshenfenlist() {
				this.loding = true
				this.$store
					.dispatch('getshenfenlist', {
						token: this.userInfo.token,
						open_id: this.userInfo.openid

					})
					.then(res => {
						console.log(res)
						this.student = res.data.data.arr_student
						this.teacher = res.data.data.arr_teacher
						this.eduadmin = res.data.data.arr_eduadmin
						this.loding = false
					});

			},
			toindex(item, index) {
				uni.setStorageSync("abc", item)
				uni.setStorageSync("def", index)
				if (this.imlogin) {
					this.outim()
				}
				uni.navigateBack({
					delta: 1
				})
			},
			outim() {
				this.$store.dispatch("timLogOut").then(res => {})

			}
		},
		onLoad() {
			this.getshenfenlist()

		}
	}
</script>

<style lang="less">
	page {
		background-color: #f4f4f4;
	}

	.content {
		.list:nth-child(1) {
			border: 0;
		}

		.list {
			position: relative;
			background-color: #fff;
			width: 100%;
			display: flex;
			flex-direction: column;
			font-size: 28rpx;
			border-top: 2px solid #ccc;
			color: #ccc;
			padding: 20rpx;
			box-sizing: border-box;

			.usershenfen {
				font-size: 35rpx;
				color: #000000;
				margin-bottom: 10rpx;

				.bzr {
					padding: 5rpx 20rpx;
					border-radius: 10rpx;
					background-color: #0a98f7;
					color: #fff;
					font-size: 25rpx;
					margin-left: 10rpx;
				}
			}

			.textboxone {
				.textbox {
					margin-right: 20rpx;
				}
			}

			.shenfen {
				padding: 8rpx 20rpx;
				border-radius: 38rpx;
				position: absolute;
				top: 40rpx;
				right: 20rpx;
				font-size: 28rpx;
				color: #fff;
				background-color: #fda64a;

			}
		}

	}
</style>
